package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Family;
import cn.wolfcode.crm.mapper.FamilyMapper;
import cn.wolfcode.crm.query.QueryForObject;
import cn.wolfcode.crm.service.IFamilyService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FamilyServiceImpl implements IFamilyService {
    @Autowired
    private FamilyMapper mapper;

    public void deleteByPrimaryKey(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    public void insert(Family record) {
        mapper.insert(record);

    }

    public Family selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<Family> selectAll() {
        return mapper.selectAll();
    }

    public void updateByPrimaryKey(Family record) {
        mapper.updateByPrimaryKey(record);
    }

    public List<Family> queryByEmpId(Long empId) {
        return mapper.queryByEmpId(empId);
    }

    public PageResult query(QueryForObject qo) {
        int total = mapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<Family> rows = mapper.queryForList(qo);

        return new PageResult(total, rows);
    }

    public void delete(Long empId) {
        mapper.deleteByPrimaryKey(empId);
    }

}
